package com.aorise.utils;

/**
 * @Auther: zhouhao
 * @Date: 2019/7/1
 * @Description:
 */
public enum OnlineEnum {

    ONLINE(1,"在线"),
    OFLINE(2,"离线");

    private Integer code;
    private String chinese;

    OnlineEnum(Integer code, String chinese) {
        this.code = code;
        this.chinese = chinese;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getChinese() {
        return chinese;
    }

    public void setChinese(String chinese) {
        this.chinese = chinese;
    }

    /**
     * 判断值是否存在
     * @param str
     * @return
     */
    public static boolean isHas(String str){
        boolean bol =false;
        for (OnlineEnum val : OnlineEnum.values()){
            if(val.getChinese().equals(str.trim())){
                bol =true;
                break;
            }
        }
        return bol;
    }

    /**
     * 根据值获取ID
     * @param value
     * @return
     */
    public static Integer getId(String value){
        Integer id = 1;
        for (OnlineEnum val : OnlineEnum.values()){
            if(val.getChinese().equals(value.trim())){
                id = val.getCode();
                break;
            }
        }
        return id;
    }
}
